//
// Created by lenovo on 2023/11/30.
//

#if 0
int arr[30];

int main()
{
    int n = 0, r = 0;
    cin >>  n >> r;
    for(int i = r + 1;i <= n;i++)
    {
        arr[i] = 1;
    }
    do
    {
        for(int i = 1;i <= n;i++)
        {
            if(arr[i] == 0)
                cout << setw(3) << i;
        }
        cout << endl;

    }
    while(next_permutation(arr + 1,arr + n + 1));

    return 0;
}

int main()
{
    int arr[10] = { 0 };
    for(int i = 0 ;i < 10;i++)
    {
        arr[i]= i + 1;
    }
    int m = 0;
    cin >> m;
    do {
        for(int i = 0;i < m;i++)
        {
            cout << setw(3) << arr[i];
        }
        cout << endl;
    }
    while(next_permutation(arr, arr + m));


    return 0;
}

int arr[100003];
int main()
{
    int n = 0, m = 0;
    cin >> n >> m;
    for(int i = 0;i < n;i++)
    {
        cin >> arr[i];
    }
  while(m--)
  {
      next_permutation(arr, arr + n);
  }
  for(int i = 0;i < n;i++)
  {
      cout <<  arr[i]<< " " ;
  }
    return 0;
}


#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int n = 7;
    cout << setfill('*') << setw(9) << n;
    cout << endl;
    for(int i = 1;i < 10;i++)
    {
        cout << i;
    }

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
char arr[103][103];
long long  r= 0, c = 0, k =0;
long  ans = 0;

int main() {

    cin >> r >> c >> k ;
    for(int i = 0;i < r;i++)
    {
        for(int j = 0;j < c; j++)
        {
            cin >> arr[i][j];
        }
    }
    bool f = true;
    for(int i = 0; i < r;i++)
    {
        for(int j = 0; j < c;j++)
        {
             f = true;
           for(int s = 0;s < k;s++)
           {
               if(arr[i + s][j] != '.')
               {
                   f = false;
                   break;
               }
           }
            if(f == true)
            {
                ans++;
            }
        }
    }

    for(int i = 0;i < r;i ++){
        for(int j = 0;j < c;j++)
        {
            f = true;
            for(int s = 0;s < k;s++)
            {
                if(arr[i][j + s] != '.')
                {
                    f = false;
                    break;
                }
            }
            if(f == true)
                ans++;
        }
    }
   if(k == 1)
       cout << ans / 2;
    else
        cout << ans;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define true 1
#define false 0

bool prim (int n)
{
    if(n == 1)
        return true;
    if(n % 2 == 0)
        return false;

    else
    {
        for(int i = 2;i <= (int)sqrt(n);i++)
        {
            if(n % i == 0)
            {
                return false;
            }
        }
            return true;

    }
}
bool hui(int t )
{
    int tem = 0, k = t;
    while(t != 0)
    {
        tem = tem * 10 + t % 10;
        t /= 10;
    }
    if(tem == k)
        return true;
    else
        return false;
}
int main()
{
    int a = 0, b = 0;
    cin >> a >> b;
    for(int i = a;i <= b;i++)
    {
        if(i==9989900)//完美卡点
            break;
        if(hui(i) && prim(i) )//细节！！
            cout << i << endl;
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a, b , c, d;
    cin >> a >> b >> c >> d;
    int s1[25], s2[25], s3[25], s4[25], t = 4;
    int sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0;
    int ans1 = 0, ans2 = 0, ans3 = 0,ans4 = 0;
  for(int i = 0;i < a;i++)
  {
      cin >> s1[i];
      if(a == 1)
          sum1 = s1[i];
      else
          ans1+=s1[i];

  }
  for(int i = 0;i < b;i++)
  {
      cin >> s2[i];
      if(b == 1)
          sum2 = s2[i];
      else
          ans2+=s2[i];
  }
  for(int i = 0;i < c;i++)
  {
      cin >> s3[i];
      if(c == 1)
          sum3 = s3[i];
      else
          ans3+= s3[i];
  }
  for(int i = 0;i < d;i++)
  {
      cin >> s4[i];
      if(d == 1)
          sum4 = s4[i];
      else
          ans4+=s4[i];
  }
  int ans = 0;
  ans = sum1 + sum2 + sum3 + sum4 + ceil(ans1 / 2.0) + ceil(ans2 / 2.0) + ceil(ans3 / 2.0) + ceil(ans4 / 2.0);
  cout << ans;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n, f[30];

int main()
{
    cin >> n;
    f[0] = 1, f[1] = 1;
    for(int i = 2;i <= n;i++)
    {
        for(int j = 0;j < i;j++)
        {
            f[i] += f[j] * f[i - j - 1];
        }
    }
    cout << f[n];
    return 0;
}
#endif
#include<iostream>
#include<cstring>

using namespace std;
string f()
{
    string s1 = "", s2;
    char ch;
    int t;
    while(cin >> ch)
    {

        if(ch == '[')
        {
            cin >> t;
            s2 = f();
            while(t--)
            {
                s1 += s2;
            }
        }
        else
        {
            if(ch == ']')
                return s1;
            else
                s1+=ch;
        }

    }
}
int main()
{
    cout << f();

    return 0;
}
